package com.five.monkey.feign.consumer.client;

import com.five.monkey.feign.consumer.client.fallback.GraphFeignClientFallback;
import com.five.monkey.vo.CommonVo;
import com.five.monkey.vo.GraphVo;
import com.five.monkey.vo.PageVo;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * @author 狻猊
 * @date 2021/8/10 下午2:14
 */
@FeignClient(value = "feign-provider", path = "/provider/graph", fallback = GraphFeignClientFallback.class)
public interface GraphFeignClient {

    @GetMapping(value = "/find/by/{id}", consumes = "application/json")
    CommonVo<GraphVo> findById(@PathVariable("id") Long id);

    @GetMapping(value = "/find/by/user/{userId}", consumes = "application/json")
    CommonVo<List<GraphVo>> findByUserId(@PathVariable("userId") Long userId);

    @PostMapping(value = "/save/to/elasticsearch", consumes = "application/json")
    CommonVo<GraphVo> saveToElasticsearch(@RequestBody GraphVo graphVo);

    @GetMapping(value = "/find/by/{id}/elasticsearch", consumes = "application/json")
    CommonVo<GraphVo> findByIdFromElasticsearch(@PathVariable("id") Long id);

    @DeleteMapping(value = "/delete/by/{id}/elasticsearch", consumes = "application/json")
    CommonVo<Boolean> deleteByIdFromElasticsearch(@PathVariable("id") Long id);

    @GetMapping(value = "/find/all/elasticsearch", consumes = "application/json")
    CommonVo<List<GraphVo>> findAllFromElasticsearch();

    @GetMapping(value = "/page/by/{status}/elasticsearch", consumes = "application/json")
    CommonVo<PageVo<GraphVo>> pageByStatusFromElasticsearch(@PathVariable("status") Integer status, @RequestParam(value = "page") int page,
                                                                   @RequestParam(value = "size", required = false, defaultValue = "10") int size);

    @GetMapping(value = "/list/by/{status}/elasticsearch", consumes = "application/json")
    CommonVo<List<GraphVo>> listByStatusFromElasticsearch(@PathVariable("status") Integer status);
}
